package org.alternativedev.wo42.map.maps;

import org.alternativedev.wo42.Game;
import org.alternativedev.wo42.enums.NPCMovement;
import org.alternativedev.wo42.gameobjects.entities.EntityNPC;
import org.alternativedev.wo42.gameobjects.entities.npcs.EntityNPCHostileEvilguy;
import org.alternativedev.wo42.gameobjects.items.ItemCoin;
import org.alternativedev.wo42.map.Map;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public class MapStart extends Map {

	private static String mapFile = "data/level1.tmx";
	private static String mapMusic = "data/music/main.ogg";
	private static String deathMusic = "data/music/death.ogg";

	private EntityNPC stupidNPC = new EntityNPC(90, 90, new Image[] {
			new Image("data/mnv2_bk1.png"), new Image("data/mnv2_bk2.png") },
			new Image[] { new Image("data/mnv2_fr1.png"),
					new Image("data/mnv2_fr2.png") }, new Image[] {
					new Image("data/mnv2_lf1.png"),
					new Image("data/mnv2_lf2.png") }, new Image[] {
					new Image("data/mnv2_rt1.png"),
					new Image("data/mnv2_rt2.png") }, new int[] { 300, 300 });
	private EntityNPCHostileEvilguy evilNPC = new EntityNPCHostileEvilguy(150, 150);

	public MapStart() throws SlickException {
		super(mapFile, mapMusic, deathMusic);
		this.addItem(new ItemCoin(60, 60));
		stupidNPC.setMove(NPCMovement.RECTANGLE, 0.1f);
		evilNPC.setMove(NPCMovement.RANDOM, 0.1f);
		evilNPC.say("I AM ULTRASUPERDUPERMEGAHEFTICH EVIL!\nbla\nbla");
		this.addEntity(stupidNPC);
		this.addEntity(evilNPC);
	}

	int waitNPC = 0;

	@Override
	public void update(GameContainer gc, int delta, Game game)
			throws SlickException {
		super.update(gc, delta, game);
		waitNPC++;
		if (stupidNPC.collidesWith(this.getPlayer())) {
			waitNPC = 0;
			stupidNPC.setInterrupted(true);
			stupidNPC.say("TUA MATER!");
		} else if(waitNPC > 60){
			waitNPC = 0;
			stupidNPC.setInterrupted(false);
			stupidNPC.stopSaying();
		}
	}

}
